<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>reduceRight</title>

  <script>

    /**
     * reduceRight(callback,[initialValue])方法接受一个函数作为累加器（accumulator）和数组的每个值（从右到左）将其减少为单个值。
     * 返回值：执行之后的返回值。
     */

    let array = [1, 2, 3, 4, 5];

    const result = array.reduceRight((per, cur) => {
      console.log(per);
      return "" + per + cur
    })

    console.log(result); // 54321

  </script>
</head>

<body>

</body>

</html>